package com.base;

import android.app.ProgressDialog;
import android.content.Context;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.dingqb.mycs.R;

/**
 * 数据加载提示dialogue
 */
public class MyProgressDialog extends ProgressDialog {
	private TextView tvMsg;
	private CharSequence mShowMsg;

	private AnimationDrawable anim;

	public MyProgressDialog(Context context) {
		super(context);
	}

	public MyProgressDialog(Context context, int theme) {
		super(context, theme);
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.dialog_loading_progress);
		tvMsg = (TextView) findViewById(R.id.loading_progress_message);
		if (!TextUtils.isEmpty(mShowMsg))
			tvMsg.setText(mShowMsg);
		else
			tvMsg.setVisibility(View.GONE);
	}

	@Override
	protected void onStop() {
		super.onStop();
		if (anim != null) {
			anim.stop();
		}
	}

	@Override
	public void setMessage(CharSequence message) {
		mShowMsg = message;
		if (null != tvMsg)
			tvMsg.setText(mShowMsg);
	}

}
